import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:webview_flutter/webview_flutter.dart';

import '../controller/web_controller.dart';

///网页加载
class WebPage extends StatelessWidget {
  WebPage({super.key});

  final WebController controller = Get.put(WebController());

  @override
  Widget build(BuildContext context) {
    return PopScope(
      child: Scaffold(
        appBar: AppBar(title: Obx(() => Text(controller.tittle.value))),
        body: WebViewWidget(controller: controller.webController),
      ),
      onPopInvoked: (bool didPop) async {
        if(await controller.webController.canGoBack()){
          controller.webController.goBack();
        }
      },
    );
  }
}
